<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<script type="text/javascript" src="../js/jquery-3.1.0.min.js"></script>
<style type="text/css">
.shop{width: 550pt;height: 600pt}
</style>
<title>Insert title here</title>
<script>
var currentpage =${currentpage} ;
var totalpage =${totalpage};
$(document).ready(function(){
	
	$("#firest").click(function(){
		currentpage=1;
		getList();
	})
	$("#up").click(function(){
		if(currentpage==1){
			alert("当前已经为第一页了");
		}else{
			currentpage--;
			getList();
		}
	});
	$("#down").click(function(){
		if(currentpage==totalpage){
			alert("当前页已经是最后一页");
		}else{
			currentpage++;
			getList();
		}
	});
		$("#end").click(function(){
			currentpage=totalpage;
			getList();
		})
		$(".add").click(function(){
			location.href="GetListGoodsTypeServlet";
		})
		$(".search").click(function(){
			currentpage=1;
			getList();
		})
		$(".del").click(function(){
										if(confirm("是否确定删除")){
											location.href="delGoodsTypeServlet?&currentpage="+currentpage;
										}
									});
		 $(".update").click(function(){
			 $(this).prop("disable",true);
									  location.href="UpdateorderServlet?state="+$(this).attr("id")+"&id="+$(this).parents("td").prevAll(".id").html();
									})
		function getList(){
			location.href="GetListorderServlet?currentpage="+currentpage;
		}
})
</script>
</head>
<body>
<div class="shop">
商品名称：<input type="text" >
<input type="button" value="搜索" class="search"><br>
<h3 align="right" >订单总价为：${totalPrice}元</h3>
	<table border="1" class="goods" >
		<tr>
			<th>订单id</th>
			<th>商品名称</th>
			<th>商品价格</th>
			<th>购买数量</th>
			<th>订单状态</th>
			<th>订单总价</th>
			<th>操作</th>
		</tr>
		<c:forEach items="${list}" var ="order">
		<tr>
		<td class="id">${order.order_id}</td>
		<td >${order.goods.gName}</td>
		<td >${order.goods.gPrice}</td>
		<td  >${order.goods_num}</td>
		<td  class="${order.order_state}">${order.order_state}</td>
		<td >${order.goods_num*order.goods.gPrice}</td>
		<td>
		       <input type="button" value="付款" class="update" id="0" >
				<input type="button" value="确认收货" class="update" id="3">
			</td>
		</tr>
		</c:forEach>
	</table>
	<input type="button" value="第一页" id= "firest">
	<input type="button" value="上一页" id ="up">
	<input type="button" value="下一页" id = "down">
	<input type="button" value="最后一页" id = "end">
	${currentpage}/${totalpage}
		</div>
		<script>
		$(".0").html("未付款");
		$(".1").html("已付款未发货");
		$(".2").html("已发货");
		$(".3").html("发货完成");
		</script>
</body>
</html>